﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

using System.ComponentModel;
using System.IO.IsolatedStorage;
using ActivityTracker.Library;
using Common.Library;


namespace ActivityTracker
{
    public partial class ProgressMenu : PhoneApplicationPage
    {
        #region Global

        string actId = "";
        string hisId = "";
        string actStartDate = "";
        Charts objCharts = new Charts();

        #endregion

        #region constructor

        public ProgressMenu()
        {
            InitializeComponent();
        }

        #endregion

        #region Events

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                NavigationContext.QueryString.TryGetValue("actId", out actId);
                NavigationContext.QueryString.TryGetValue("hisId", out hisId);
                NavigationContext.QueryString.TryGetValue("actStartDate", out actStartDate);
                lbxProgress.ItemsSource = objCharts.LoadProgressChartMenu(actId);
            }
            catch (Exception ex)
            {
                string mess = "Exception in PhoneApplicationPage_Loaded Method In ProgressMenu file.\n\n" + ex.Message + "\n\n Stack Trace:- " + ex.StackTrace;
                Exceptions.SaveOrSendExceptions(mess, ex);
            }
        }

        private void lbxProgress_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbxProgress.SelectedIndex == -1)
                return;
            switch (lbxProgress.SelectedItem.ToString())
            {
                case "daily":
                    NavigationService.Navigate(new Uri("/Views/Charts/Daily/Daily_ProgressBarChart.xaml?actId=" + actId, UriKind.Relative));
                    break;
                case "monthly":
                    NavigationService.Navigate(new Uri("/Views/Charts/Monthly/Monthly_ProgressBarChart.xaml?actId=" + actId + "&actStartDate=" + actStartDate, UriKind.Relative));
                    break;
                case "yearly":
                    NavigationService.Navigate(new Uri("/Views/Charts/Yearly/Yearly_ProgressBarChart.xaml?actId=" + actId, UriKind.Relative));
                    break;
                case "activity map":
                    NavigationService.Navigate(new Uri("/Views/Maps/MapDisplay.xaml?actId=" + actId + "&hisId=" + hisId, UriKind.Relative));
                    break;
            }
            lbxProgress.SelectedIndex = -1;
        }

        private void imgHelp_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/Help/Help.xaml?id=4&url=Ax4NRtZhx4U", UriKind.Relative));
         
        }

        #endregion
    }
}